﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

namespace CrossRoadNS.Services.Converters
{
    class IntToColorConv : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SolidColorBrush result = new SolidColorBrush();

            int iValue = (int)value;

            byte r = (byte)(iValue & 0xFF);
            byte g = (byte)(iValue >> 8 & 0xFF);
            byte b = (byte)(iValue >> 16 & 0xFF);

            result.Color = Color.FromRgb(r, g, b);
            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
